#ifndef SERIALPORTMANAGER_H
#define SERIALPORTMANAGER_H
#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>
#include "singleton.h"
class SerialPortManager:public QObject, public Singleton<SerialPortManager>
{
	Q_OBJECT
public:
    void OpenComLight();
    void OpenComHandler();
    void StopComLight();
    void StopComHandler();
	void SendBuffer(char *resBuf, uint8_t length);
    void SendResult(bool bSite0, uint8_t bResult);
	void SendVersion();
	void SendNextPos(int x, int y);
    //void TurnOffRedLight();
    //void TurnOffWhiteLight();
	void GetLightBrightnessA();
	void GetLightBrightnessB();
	void GetLightBrightnessC();
	void GetLightBrightnessD();
    
    void SetLightBrightnessA(uint8_t light);
	void SetLightBrightnessB(uint8_t light);
	void SetLightBrightnessC(uint8_t light);
	void SetLightBrightnessD(uint8_t light);
	//void SetWhiteLightBrightness(uint8_t light);
	void SetTwoLightBrightnessSync(uint8_t red, uint8_t blue);
	void SetThreeLightBrightnessSync(uint8_t red, uint8_t blue, uint8_t white);
	void SetFourLightBrightnessSync(uint8_t red, uint8_t blue, uint8_t white, uint8_t white2);
	
	QSerialPort * GetHandlerCom()
	{
		return m_comHandler;
	}
	QSerialPort * GetLightCom()
	{
		return m_comLight;
	}
protected:
    SerialPortManager();
    friend class Singleton<SerialPortManager>;
private:
    QSerialPort *m_comLight;
    QSerialPort *m_comHandler;
	bool m_bIsStrobe;
	void WaitForWriteAndClose();
	void InitController();
	void SetExternalTrigger(bool b);
	void SetLightDelay(int ch, int delay);
	void SetAllDelay(int delays[], int count);
	void SetLightWidth(int ch, int width);
	void SetAllWidth(int width1, int width2, int width3);
//signals:
//	void setLightEvent();
};

#endif // SERIALPORTMANAGER_H
